package cc.booku.owlbox.OrdinaryVideo_norm;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.TextView;


import java.util.ArrayList;
import java.util.concurrent.Executors;

import cc.booku.owlbox.R;

public class OrdinaryVideo_A extends BaseAdapter implements ListAdapter {


    private ArrayList<OrdinaryVideo_C> ordinaryVideo_cArrayList;
    private int id;
    private Context context;
    private LayoutInflater inflater;

    public OrdinaryVideo_A(int item, Context context, ArrayList<OrdinaryVideo_C> ordinaryVideo_cArrayList) {
        this.ordinaryVideo_cArrayList = ordinaryVideo_cArrayList;
        this.context = context;
        this.id = item;
        inflater = LayoutInflater.from(context);

    }

    @Override
    public int getCount() {
        return ordinaryVideo_cArrayList.size();
    }

    @Override
    public Object getItem(int i) {
        return ordinaryVideo_cArrayList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @SuppressLint("WrongConstant")
    @Override

    public View getView(int i, View view, ViewGroup viewGroup) {


        TextView vod_id = null;
        TextView vod_name = null;
        TextView vod_class = null;
        TextView vod_add_time = null;
        TextView vod_play_url = null;


        OrdinaryVideo_A.ViewHolder viewHolder;
        if (view == null) {
            view = inflater.inflate(id, null);

            vod_id = (TextView) view.findViewById(R.id.vod_id);
            vod_name = (TextView) view.findViewById(R.id.vod_name);
            vod_class = (TextView) view.findViewById(R.id.vod_class);
            vod_add_time = (TextView) view.findViewById(R.id.vod_add_time);
            vod_play_url = (TextView) view.findViewById(R.id.vod_play_url);


            view.setTag(new ViewHolder(vod_id, vod_name, vod_class, vod_add_time, vod_play_url));
        } else {
            OrdinaryVideo_A.ViewHolder viewHolder1 = (OrdinaryVideo_A.ViewHolder) view.getTag(); // 重新获取ViewHolder
            vod_id = viewHolder1.vod_id;
            vod_class = viewHolder1.vod_class;
            vod_name = viewHolder1.vod_name;
            vod_add_time = viewHolder1.vod_add_time;
            vod_play_url = viewHolder1.vod_play_url;

        }
        OrdinaryVideo_C ordinaryVideoC = (OrdinaryVideo_C) ordinaryVideo_cArrayList.get(i); // 获取当前项的实例

        //video_public_classListc
        vod_name.setText(ordinaryVideoC.getVod_name().toString());//对象为空
        vod_class.setText(ordinaryVideoC.getVod_class().toString());
        vod_id.setText(ordinaryVideoC.getVod_id().toString());
        vod_add_time.setText(ordinaryVideoC.getVod_add_time().toString());
        vod_play_url.setText(ordinaryVideoC.getVod_play_url().toString());

        return view;

    }


    private final class ViewHolder {
        TextView vod_id = null;
        TextView vod_name = null;
        TextView vod_class = null;
        TextView vod_add_time = null;

        TextView vod_play_url = null;


        public ViewHolder(TextView vod_id, TextView vod_name, TextView vod_class, TextView vod_add_time, TextView vod_play_url) {
            this.vod_class = vod_class;
            this.vod_id = vod_id;
            this.vod_name = vod_name;
            this.vod_add_time = vod_add_time;
            this.vod_play_url = vod_play_url;

        }

    }
}
